home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
133_01
/
ehaze
< prev
next >
Wrap
Text File
|
1985-03-09
|
8KB
|
251 lines
/*
e screen editor
(C) G. Nigel Gilbert, MICROLOGY, 1981
August-December 1981
FILE: ehaze
FUNCTIONS: terminal,gotoxy,deleteline,linedelete,delpage,
insertline,begdim,enddim,keytranslate,displayhelp
PURPOSE: terminal dependent screen control functions
NOTE this file is specific to the HAZELTINE range of terminals.
NOTE ALSO that the terminal must be set to use TILDE as the lead -in
character, not Escape.
*/
#include "e.h"
/* ASCII control key codes, here for convenience in defining terminal sequences*/
#define CTRLA 0x01 /* SOH */
#define CTRLB 0x02 /* STX */
#define CTRLC 0x03 /* ETX */
#define CTRLD 0x04 /* EOT */
#define CTRLE 0x05 /* ENQ */
#define CTRLF 0x06 /* ACK */
#define CTRLG 0x07 /* BEL */
#define CTRLH 0x08 /* BS */
#define CTRLI 0x09 /* HT */
#define CTRLJ 0x0a /* LF */
#define CTRLK 0x0b /* VT */
#define CTRLL 0x0c /* FF */
#define CTRLM 0x0d /* CR */
#define CTRLN 0x0e /* SO */
#define CTRLO 0x0f /* SI */
#define CTRLP 0x10 /* DLE */
#define CTRLQ 0x11 /* DC1 */
#define CTRLR 0x12 /* DC2 */
#define CTRLS 0x13 /* DC3 */
#define CTRLT 0x14 /* DC4 */
#define CTRLU 0x15 /* NAK */
#define CTRLV 0x16 /* SYN */
#define CTRLW 0x17 /* ETB */
#define CTRLX 0x18 /* CAN */
#define CTRLY 0x19 /* EM */
#define CTRLZ 0x1a /* SUB */
#define SOH 0x01
#define STX 0x02
#define ETX 0x03
#define EOT 0x04
#define ENQ 0x05
#define ACK 0x06
#define BEL 0x07
#define BS 0x08
#define HT 0x09
#define LF 0x0a
#define VT 0x0b
#define FF 0x0c
#define RETURN 0x0d
#define SO 0x0e
#define SI 0x0f
#define DLE 0x10
#define DC1 0x11
#define DC2 0x12
#define DC3 0x13
#define DC4 0x14
#define NAK 0x15
#define SYN 0x16
#define ETB 0x17
#define CAN 0x18
#define EM 0x19
#define SUB 0x1a
#define ESC 0x1b
#define FS 0x1c
#define GS 0x1d
#define RS 0x1e
#define US 0x1f
#define DEL 0x7f
/*-------------------------OUTPUT TO SCREEN---------------------------*/
/* screen control characters for Hazeltine 1420 (and probably other
Hazeltines as well) */
#define TILDE 0x7e
#define BEGINDIM EM /*all these are preceded by a lead in tilde */
#define ENDDIM US
#define CRSADDR DC1
#define INSLINE SUB
#define DELLINE SI /*delete to spaces*/
#define LINDEL DC3 /*delete and close up*/
#define PAGEDEL CAN
terminit() /*initialise terminal. Called once before any output to
to terminal is performed */
{
}
termfini() /*restore terminal to 'normal' state. Called once before
program exits */
{
}
terminal() /*display name of terminal */
{
puts("|for Hazeltine");
}
gotoxy(x,y) /*move cursor to column x, line y {top left is (0,0) */
int x,y;
{
putch(TILDE);
putch(CRSADDR);
putch(x);
putch(y);
}
deleteline(x,y) /*clear to spaces all characters on line y from column x
to the right edge of the screen, inclusive.
Leave cursor on left most blank */
int x, y;
{
gotoxy(x,y);
putch(TILDE);
putch(DELLINE);
gotoxy(x,y);
}
linedelete(y) /*delete the line y. All following lines move up one.
Leave cursor at start of line y */
int y;
{
gotoxy(0,y);
putch(TILDE);
putch(LINDEL);
}
delpage(y) /*clear to spaces line y and all following lines. Leave
cursor at the start of line y */
int y;
{
gotoxy(0,y);
putch(TILDE);
putch(PAGEDEL);
}
insertline() /*move all lines below line on which cursor is, down one,
losing last line. New cursor line is blank, with
cursor at start of line */
{
putch(TILDE);
putch(INSLINE);
}
begdim() /*display all subsequent characters at half intensity*/
{
putch(TILDE);
putch(BEGINDIM);
}
enddim() /* display all subsequent characters at full intensity */
{
putch(TILDE);
putch(ENDDIM);
}
/*----------------------INPUT FROM KEYBOARD-----------------------------*/
keytranslate() /*defines the terminal key codes which perform
the editor commands */
{
/* each tran[xxxx]= should be set to the code emitted by the terminal
key which will perform the indicated action. The recommended (control)
key assignments are shown in round brackets.
Some terminals precede their codes by a lead-in character
(eg the Hazeltine uses the tilde). This char should be assigned to
tran[LEADIN]. If there is no lead-in character, set tran[LEADIN] to zero.
'e' will ignore the leadin character if tran[LEADIN] is non-zero,
but will set the parity bit on the next character. All other chars from the
keyboard will already have any parity bits removed as they are read in. Thus
codes with lead-ins should be entered in the table below as code+0x80, or
more clearly, as code+PARBIT.
For example, suppose that one is coding the Hazeltine 1420, which
generates a tilde,^L (0x0d) sequence when the cursor up key is pressd. To
recognise this sequence, set tran[LEADIN] to tilde (0x7e) and set
tran[UPKEY] to 0x0d+0x80, or, equivalently, to CTRLL+PARBIT.
*/
tran[LEADIN]=TILDE; /*lead-in character, 0 if not used*/
tran[DOWNKEY]= VT+PARBIT; /*cursor down */
tran[UPKEY]= FF+PARBIT; /*cursor up*/
tran[LEFTKEY]= BS; /*cursor left*/
tran[RIGHTKEY]= DLE; /*cursor right*/
tran[RIGHTWKEY]= CTRLD; /*cursor right one word (D) */
tran[LEFTWKEY]= CTRLS; /*cursor left one word (S) */
tran[EOLKEY]= CTRLE; /*cursor to end of line (E) */
tran[BOLKEY]= CTRLB; /*cursor to beginning of line (B) */
tran[UPPAGE]= CTRLW; /*scroll up a page (W) */
tran[DOWNPAGE]= CTRLZ; /*scroll down a page (Z) */
tran[BOFKEY]= CTRLU; /*cursor to beginning of file (U) */
tran[HOMEKEY]= DC2+PARBIT; /*cursor to end of file (HOME) */
tran[DELLEFT]= DEL; /*delete char to left of cursor (DEL) */
tran[DELRIGHT]= CTRLG; /*delete char under cursor (G) */
tran[DELLNKEY]= CTRLY; /*delete cursor line (Y) */
tran[DELWDKEY]= CTRLT; /*delete word to right of cursor (T) */
tran[JUMPKEY]= CTRLX; /*jump to (X) */
tran[CRSTILL]= CTRLN; /*insert newline after cursor (N) */
tran[QUITKEY]= CTRLQ; /*quit (Q) */
tran[ENVIRKEY]= CTRLC; /*edit and file context (C) */
tran[FINDKEY]= CTRLF; /*find (F) */
tran[ALTERKEY]= CTRLA; /*alter (A) */
tran[BLOCKKEY]= CTRLO; /*block operations (O) */
tran[RDFILEKEY]= CTRLK; /*read a file (P) */
tran[REPKEY]= CTRLR; /*repeat last find/alter (R) */
tran[HELPKEY]= CTRLV; /*display help menu (V) */
tran[UNDOKEY]= FS; /*restore unedited line (\) */
tran[TAB]= CTRLI; /*tab (I) */
tran[RETRIEVE]= CTRLR; /*retrieve (R)*/
tran[CR]= CTRLM; /*return*/
tran[ESCKEY]=ESC; /*escape, the magic key (ESC)*/
}
/*-------------------------------HELP MENU-------------------------------*/
displayhelp() /*display the help menu. There must be (helplines-1)
lines of menu here (see terminal function,above) */
{
puts("CURSOR: ^B|=beginning of line| ^E|=end of line| ^S|=left word| ^D|=right word\n");
puts("MOVE: ^W|=up a screen| ^Z|=down a screen| ^U|=top, |HOME|=bottom of file\n");
puts("DELETE: DEL|=char left| ^G|=char right| ^T|=word| ^Y|=line| ^\\|=undo\n");
puts(" ^F|=find| ^A|=alter| ^R|=repeat| ^V|=view menu\n");
puts(" ^ ^N|=insert a new line| ^X|=jump to line| ^K|=read file| ^Q|=quit,save file\n");
puts(" <- -> ^C|=edit,file context| ^O|=write,print,shift,move,copy,or delete block\n");
puts("---v------------------------------------------------------------------------");
}
/*---------------------------------END---------------------------------------*/
tran[BOFKEY]= CTRLU; /*cursor to beginning of file (U) */
tran[HOMEKEY]= DC2+PARBIT; /*cursor to